package com.wuxiaofan.order.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.order.entity.Order;
import com.wuxiaofan.order.entity.custom.OrderCustom;
import com.wuxiaofan.order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.order.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class OrderService {
    @Autowired
    private OrderMapper omsOrderMapper;
    @Resource
    private Idgenerator idgenerator;
    public Order findById(String id){
        return omsOrderMapper.selectById(id);
    }

    public OrderCustom findCountByMap(Map paraMap){
        return omsOrderMapper.findCountByMap(paraMap);
    }

    public OrderCustom findGroupByMap(Map paraMap){
        return omsOrderMapper.findGroupByMap(paraMap);
    }

    public List<OrderCustom> findByMap(Map paraMap){
        return omsOrderMapper.findByMap(paraMap);
    }

    public Page<OrderCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(omsOrderMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        omsOrderMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        omsOrderMapper.deleteById(id);
    }

    public Order save(Order omsOrder){
        omsOrder.setId(idgenerator.getId());
        omsOrderMapper.insert(omsOrder);
        return omsOrder;
    }

}
